package servlet;

import java.io.IOException;
import java.util.Vector;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import dto.Department;
import schoolDAO.DepartmentDAO;


public class RegisterDepartmentServlet extends HttpServlet {


	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		System.out.print("111111111111111111");
		    String depart = req.getParameter("depart");
		    String mId = req.getParameter("mId");
			String cName = req.getParameter("cName");
			String dName = req.getParameter("dName");
			DepartmentDAO dd = new DepartmentDAO();
			Department d = new Department();
			d.setdepart(depart);
			d.setmId(mId);
			d.setcName(cName);
			d.setdName(dName);
			boolean flag = dd.insert(d);
			System.out.print("2");
			Vector v=dd.findAllDepartment();
			HttpSession session= req.getSession();
			session.setAttribute("allDepartment",v);
			if(flag){
				resp.sendRedirect(req.getContextPath()+"/admin/allDepartment.jsp");
			}else{
				resp.sendRedirect(req.getContextPath()+"/error.html");
			}		
	}
	
}
